package logic

import (
	"context"
	"house-manage/model"

	"house-manage/houserpc/houserpc"
	"house-manage/houserpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseShowLogic {
	return &HouseShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 列表详情
func (l *HouseShowLogic) HouseShow(in *houserpc.HouseShowRequest) (*houserpc.HouseShowResponse, error) {
	// todo: add your logic here and delete this line
	var data model.House
	err := data.HouseShow(model.DB, int(in.HouseId))
	if err != nil {
		return nil, err
	}
	return &houserpc.HouseShowResponse{
		HouseId:   int64(data.ID),
		HouseName: data.HouseName,
		Address:   data.Address,
	}, nil
}
